package sto.orz.rptp.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

@Entity
@sto.orz.html.Form
public class Dataset {
	@sto.orz.html.Element(label = "数据源", mapping = "datasource.id")
	@sto.orz.html.Select(display = "datasource.name")
	private Datasource datasource;

	@sto.orz.html.Element(label = "ID")
	private String id;

	@sto.orz.html.Element(label = "名称")
	private String name;

	@sto.orz.html.Element(label = "查询")
	private String query;

	public Dataset() {
	}

	public Dataset(String name) {
		this.name = name;
	}

	public Dataset bindDatasource(Datasource datasource) {
		setDatasource(datasource);
		return this;
	}

	@ManyToOne
	@JoinColumn(name = "datasource_id")
	public Datasource getDatasource() {
		return datasource;
	}

	@Id
	@GeneratedValue(generator = "system-uuid")
	@org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getQuery() {
		return query;
	}

	public void setDatasource(Datasource datasource) {
		this.datasource = datasource;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void setQuery(String query) {
		this.query = query;
	}
}
